Attribute VB_Name = "MainSubs"
'====================================================================================
'MainSubs - Everything passes through here
'====================================================================================
Option Explicit

Public Const AppTitle = "Pac Mar Level Editor"

Public Type PMLE_GFX
    'Pickups
    Cookie As New ImageTGA
    Heart As New ImageTGA
    'Sprites
    Mar As New ImageTGA
    Zim As New ImageTGA
    Dib As New ImageTGA
    Kroc As New ImageTGA
    Gir As New ImageTGA
End Type
Public gfx As PMLE_GFX

'====================================================================================
'SUB MAIN: All code starts here
'====================================================================================
Public Sub StartProgram()
    'Load the cookie
    gfx.Cookie.LoadTGA32 AppPath & "\gfx\Sprites\Cookie.tga"
    'Load the Heart (power pill)
    gfx.Heart.LoadTGA32 AppPath & "\gfx\Sprites\Heart.tga"
    
    'Load the sprites
    gfx.Mar.LoadTGA32 AppPath & "\gfx\sprites\PacMar_l.tga", True
    gfx.Zim.LoadTGA32 AppPath & "\gfx\sprites\Zim.tga", True
    gfx.Dib.LoadTGA32 AppPath & "\gfx\sprites\Dib.tga", True
    gfx.Kroc.LoadTGA32 AppPath & "\gfx\sprites\Kroc.tga", True
    gfx.Gir.LoadTGA32 AppPath & "\gfx\sprites\Gir.tga", True
    
    'Display the main game window
    Load FrmEditor
    FrmEditor.Show
End Sub

'====================================================================================
'EndProgram: A safe way to end the program and ensure everything is unloaded
'====================================================================================
Public Sub EndProgram()
    'Remove the graphics from memory
    Set gfx.Cookie = Nothing
    Set gfx.Heart = Nothing
    Set gfx.Zim = Nothing
    Set gfx.Dib = Nothing
    Set gfx.Kroc = Nothing
    Set gfx.Gir = Nothing
    
    'Don't use the End command in VB, memory isn't freed up properly, also the End
    'command often crashes VB when API calls are in use.
    
    'END OF LINE
End Sub

'=== END ============================================================================
'This work is licenced under the Creative Commons Attribution 2.5 License
